package com.aspose.cells;

class zbvl implements zaik {
   private zahn a;
   private zagu[][] b;
   private zbvj c;
   private int d;
   private int e;
   private boolean f;
   private boolean g;
   private int h;
   private int i;
   private int j;
   private int k;
   private int l;
   private int m;
   private int n;
   private int o;
   private boolean p = true;
   private zagu q;
   private zagu r;

   public zbvl(zagu[][] var1, zahn var2, zagu var3, int var4, int var5, int var6, int var7, int var8, int var9, boolean var10, boolean var11, zbvj var12) {
      this.b = var1;
      this.a = var2;
      if (var3 != null) {
         this.b(var3);
      } else {
         this.p = true;
      }

      this.j = var4;
      this.k = var5;
      this.d = var6;
      this.e = var7;
      this.h = var8;
      this.i = var9;
      this.f = var10;
      this.g = var11;
      this.c = var12;
      this.n = Math.max(0, this.j);
      this.o = Math.min(this.b.length, this.j + this.d);
      if (this.k < 0 || this.k >= this.e) {
         this.o = this.n;
      }

   }

   public zaik a(zahn var1) {
      return new zbvl(this.b, var1, this.q, this.j, this.k, this.d, this.e, this.h, this.i, this.f, this.g, this.c);
   }

   public void a() {
      this.l = this.n - 1;
   }

   public boolean b() {
      ++this.l;
      if (this.l >= this.o) {
         return false;
      } else if (this.b[this.l] == null) {
         this.b[this.l] = new zagu[this.e];
         this.r = null;
         return true;
      } else {
         this.r = this.b[this.l][this.m];
         if (!this.p && this.r == this.q) {
            ++this.l;
            if (this.l >= this.o) {
               return false;
            } else {
               do {
                  if (this.b[this.l] == null) {
                     this.b[this.l] = new zagu[this.e];
                     this.r = null;
                     return true;
                  }

                  this.r = this.b[this.l][this.m];
                  if (this.p || this.r != this.q) {
                     return true;
                  }

                  ++this.l;
               } while(this.l != this.o);

               return false;
            }
         } else {
            return true;
         }
      }
   }

   public boolean a(int var1, int var2) {
      return this.a(var1);
   }

   public boolean a(int var1) {
      var1 += this.j;
      if (var1 > this.o) {
         this.l = this.o;
         return false;
      } else if (var1 < this.n) {
         this.l = this.n - 1;
         return this.b();
      } else if (var1 == this.l) {
         return this.l < this.o;
      } else {
         this.l = var1 - 1;
         return this.b();
      }
   }

   public zagu c() {
      return this.r;
   }

   public int d() {
      return this.l - this.j;
   }

   public int e() {
      return 0;
   }

   public int f() {
      return this.l - this.j;
   }

   public zahn a(zaay var1, int var2) {
      if (this.c.a()) {
         return zbvm.a(var2, this.b, this.e, this.q, this.j, this.k, this.d, 1, this.h, this.i, this.f, this.g);
      } else {
         int var3 = this.n;

         for(var3 = this.n; var3 < this.o; ++var3) {
            if (this.b[var3] == null || this.b[var3][this.m] == null) {
               return null;
            }
         }

         if (this.n >= this.o) {
            return new zawz(this.q, var2, this.d, 1);
         } else {
            var3 = this.n;

            while(this.b[var3][this.m] == this.q) {
               ++var3;
               if (var3 == this.o) {
                  return new zawz(this.q, var2, this.d, 1);
               }
            }

            int var4 = this.o - 1;
            if (var3 == var4) {
               return new zaxh(this.b[var3][this.m], this.q, var2, this.d, 1, var3 - this.j, 0, this.h, this.i, this.f, this.g);
            } else {
               while(this.b[var4][this.m] == this.q) {
                  --var4;
                  if (var4 == var3) {
                     return new zaxh(this.b[var3][this.m], this.q, var2, this.d, 1, var3 - this.j, 0, this.h, this.i, this.f, this.g);
                  }
               }

               zagu[] var5 = new zagu[var4 - var3 + 1];
               var5[0] = this.b[var3][this.m];
               var5[var4 - var3] = this.b[var4][this.m];
               --var4;
               if (var4 > var3) {
                  do {
                     var5[var4 - var3] = this.b[var4][this.m];
                     --var4;
                  } while(var4 != var3);
               }

               return new zawg(var5, true, this.j - var3, this.d, var2, this.q, this.h, this.f);
            }
         }
      }
   }

   public zaik b(int var1) {
      var1 += this.j;
      return (zaik)(var1 >= this.n && var1 < this.o ? new zbvk(this.b[var1], this.a, this.q, this.k, 1, this.i, false, this.g, this.c) : new zbvn(this.q, 1, 1));
   }

   public zaik c(int var1) {
      return this;
   }

   public void a(zaay var1) {
      if (this.f && var1.g != this.h) {
         this.j += var1.g - this.h;
         this.n = Math.max(0, this.j);
         this.o = Math.min(this.b.length, this.j + this.d);
      }

      if (this.g && var1.h != this.i) {
         this.k += var1.h - this.i;
         if (this.k < 0 || this.k >= this.e) {
            this.o = this.n;
         }
      }

   }

   public void b(int var1, int var2) {
      this.d(var1);
   }

   public void d(int var1) {
      var1 += this.j;
      if (var1 > this.l) {
         if (this.p) {
            this.b(this.a.o());
         }

         this.b[this.l][this.m] = this.q;
         this.c.c();
         ++this.l;
         if (this.l < var1) {
            do {
               if (this.b[this.l][this.m] == null) {
                  this.b[this.l][this.m] = this.q;
                  this.c.c();
               }

               ++this.l;
            } while(this.l != var1);
         }

         this.r = this.b[this.l][this.m];
      }
   }

   public void g() {
      if (this.l < this.o) {
         if (this.p) {
            this.b(this.a.o());
         }

         this.b[this.l][this.m] = this.q;
         this.c.c();
         ++this.l;
         if (this.l < this.o) {
            do {
               if (this.b[this.l][this.m] == null) {
                  this.b[this.l][this.m] = this.q;
                  this.c.c();
               }

               ++this.l;
            } while(this.l != this.o);

         }
      }
   }

   public void a(zagu var1) {
      this.r = this.c.b(var1);
      this.b[this.l][this.m] = this.r;
   }

   public zagu c(int var1, int var2) {
      return this.e(var1);
   }

   public zagu e(int var1) {
      var1 += this.j;
      if (var1 >= this.n && var1 < this.o) {
         if (this.b[var1] == null) {
            this.b[var1] = new zagu[this.e];
            return null;
         } else {
            return this.b[var1][this.m];
         }
      } else {
         if (this.p) {
            this.b(this.a.o());
         }

         return this.q;
      }
   }

   public void a(int var1, int var2, zagu var3) {
      this.b[var1 + this.j][this.m] = this.c.b(var3);
   }

   private void b(zagu var1) {
      this.p = false;
      this.q = this.c.a(var1);
   }
}
